/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.kallsonys.object;

import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Cacheable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author allan
 */
@Entity
@Cacheable(false)
@Table(name = "PRODUCT")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Product.findAll", query = "SELECT p FROM Product p"),
    @NamedQuery(name = "Product.findByProductid", query = "SELECT p FROM Product p WHERE p.productid = :productid"),
    @NamedQuery(name = "Product.findByProductidproduct", query = "SELECT p FROM Product p WHERE p.productidproduct = :productidproduct"),
    @NamedQuery(name = "Product.findByProductname", query = "SELECT p FROM Product p WHERE p.productname = :productname"),
    @NamedQuery(name = "Product.findByProductdescription", query = "SELECT p FROM Product p WHERE p.productdescription = :productdescription"),
    @NamedQuery(name = "Product.findByProductcategory", query = "SELECT p FROM Product p WHERE p.productcategory = :productcategory"),
    @NamedQuery(name = "Product.findByProductlistPrice", query = "SELECT p FROM Product p WHERE p.productlistPrice = :productlistPrice"),
    @NamedQuery(name = "Product.findByProductproducer", query = "SELECT p FROM Product p WHERE p.productproducer = :productproducer"),
    @NamedQuery(name = "Product.findByProductimageurl", query = "SELECT p FROM Product p WHERE p.productimageurl = :productimageurl"),
    @NamedQuery(name = "Product.findByProductenable", query = "SELECT p FROM Product p WHERE p.productenable = :productenable")})
public class Product implements Serializable {
    @Lob
    @Column(name = "PRODUCTIMAGE")
    private byte[] productimage;
    @OneToMany(mappedBy = "productid")
    private List<Campaigns> campaignsList;
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    
    
    @Id
    @Basic(optional = false)
    @NotNull
    @GeneratedValue(generator="ProductSeq")
    @SequenceGenerator(name="ProductSeq",sequenceName="SEQ_PRODUCT",initialValue=1, allocationSize=1)
    @Column(name = "PRODUCTID")
    private BigDecimal productid;
    @Basic(optional = false)
    @NotNull
    @Column(name = "PRODUCTIDPRODUCT")
    private BigInteger productidproduct;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 200)
    @Column(name = "PRODUCTNAME")
    private String productname;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 4000)
    @Column(name = "PRODUCTDESCRIPTION")
    private String productdescription;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 4000)
    @Column(name = "PRODUCTCATEGORY")
    private String productcategory;
    @Column(name = "PRODUCTLIST_PRICE")
    private BigInteger productlistPrice;
    @Size(max = 4000)
    @Column(name = "PRODUCTPRODUCER")
    private String productproducer;
    @Size(max = 4000)
    @Column(name = "PRODUCTIMAGEURL")
    private String productimageurl;
    @Column(name = "PRODUCTENABLE")
    private BigInteger productenable;

    public Product() {
    }

    public Product(BigDecimal productid) {
        this.productid = productid;
    }

    public Product(BigDecimal productid, BigInteger productidproduct, String productname, String productdescription, String productcategory) {
        this.productid = productid;
        this.productidproduct = productidproduct;
        this.productname = productname;
        this.productdescription = productdescription;
        this.productcategory = productcategory;
    }

    public BigDecimal getProductid() {
        return productid;
    }

    public void setProductid(BigDecimal productid) {
        this.productid = productid;
    }

    public BigInteger getProductidproduct() {
        return productidproduct;
    }

    public void setProductidproduct(BigInteger productidproduct) {
        this.productidproduct = productidproduct;
    }

    public String getProductname() {
        return productname;
    }

    public void setProductname(String productname) {
        this.productname = productname;
    }

    public String getProductdescription() {
        return productdescription;
    }

    public void setProductdescription(String productdescription) {
        this.productdescription = productdescription;
    }

    public String getProductcategory() {
        return productcategory;
    }

    public void setProductcategory(String productcategory) {
        this.productcategory = productcategory;
    }

    public BigInteger getProductlistPrice() {
        return productlistPrice;
    }

    public void setProductlistPrice(BigInteger productlistPrice) {
        this.productlistPrice = productlistPrice;
    }

    public String getProductproducer() {
        return productproducer;
    }

    public void setProductproducer(String productproducer) {
        this.productproducer = productproducer;
    }

    public String getProductimageurl() {
        return productimageurl;
    }

    public void setProductimageurl(String productimageurl) {
        this.productimageurl = productimageurl;
    }

    public BigInteger getProductenable() {
        return productenable;
    }

    public void setProductenable(BigInteger productenable) {
        this.productenable = productenable;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (productid != null ? productid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Product)) {
            return false;
        }
        Product other = (Product) object;
        if ((this.productid == null && other.productid != null) || (this.productid != null && !this.productid.equals(other.productid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return productidproduct +"-" + productname;
    }

    @XmlTransient
    public List<Campaigns> getCampaignsList() {
        return campaignsList;
    }

    public void setCampaignsList(List<Campaigns> campaignsList) {
        this.campaignsList = campaignsList;
    }

    public byte[] getProductimage() {
        return productimage;
    }

    public void setProductimage(byte[] productimage) {
        this.productimage = productimage;
    }
    
}
